//
//  JMIPAblumCell.m
//  ImagePicker
//
//  Created by Jamin on 2018/10/16.
//  Copyright © 2018 jamin. All rights reserved.
//

#import "JMIPAblumCell.h"

#import "UIView+JMIP.h"

@implementation JMIPAblumCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    _coverImageView.jm_size = CGSizeMake(self.contentView.jm_height, self.contentView.jm_height);
    [_titleLabel sizeToFit];
    _titleLabel.jm_originX = _coverImageView.jm_right + 5.0;
    _titleLabel.jm_centerY = self.contentView.jm_height / 2.0;
    
    [_subtitleLabel sizeToFit];
    _subtitleLabel.jm_originX = _titleLabel.jm_right + 5.0;
    _subtitleLabel.jm_centerY = self.contentView.jm_height / 2.0;
}

- (UIImageView *)coverImageView {
    if (!_coverImageView) {
        _coverImageView = [UIImageView new];
        _coverImageView.clipsToBounds = YES;
        _coverImageView.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:_coverImageView];
    }
    return _coverImageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont systemFontOfSize:15.0];
        _titleLabel.textColor = [UIColor darkTextColor];
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (UILabel *)subtitleLabel {
    if (!_subtitleLabel) {
        _subtitleLabel = [UILabel new];
        _subtitleLabel.font = [UIFont systemFontOfSize:15.0];
        _subtitleLabel.textColor = [UIColor lightGrayColor];;
        [self.contentView addSubview:_subtitleLabel];
    }
    return _subtitleLabel;
}


@end
